{% extends 'cms/base.html' %}
{% block title %}
{% if news %}
编辑课程
{% else %}
发布课程
{% endif %}
{% endblock %}
{% block head %}
<script src="https://unpkg.com/qiniu-js@2.5.2/dist/qiniu.min.js"></script>
<script src="{% static 'ueditor/ueditor.config.js' %}" charset="utf-8"></script>
<script src="{% static 'ueditor/ueditor.all.min.js' %}" charset="utf-8" ></script>
<script src="{% static 'js/pub_course.min.js' %}" charset="utf-8"></script>


{% endblock %}
{% block content-header %}
<h3>
    {% if news %}
    编辑课程
    {% else %}
    发布课程
    {% endif %}
</h3>
{% endblock %}
{% block content %}
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <form action="" class="form">
                <div class="box-body">
                    <div class="form-group">
                        <label for="title-form">标题</label>
                        {% if course %}
                            <input type="text" style="display:none;" name="pk" value="{{ course.id }}">
                            <input type="text" class="form-control" name="title" id="title-form" value="{{ course.title }}">
                        {% else %}
                            <input type="text" class="form-control" name="title" id="title-form">
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="category-form">分类</label>
                        <select name="category" id="category-form" class="form-control">
                            {% for category in categories %}
                                {% if course and course.category_id == category.id %}
                                    <option value="{{category.id}}" selected>{{category.name}}</option>
                                {% else %}
                                    <option value="{{category.id}}">{{category.name}}</option>
                                {% endif %}
                            {% endfor %}
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="title-form">讲师</label>
                        {% if course %}
                            <input type="text" class="form-control" name="teacher"  value="{{ course.teacher }}">
                        {% else %}
                            <input type="text" class="form-control" name="teacher" >
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="title-form">讲师介绍</label>
                        {% if course %}
                            <input type="text" class="form-control" name="teacher_desc"  value="{{ course.teacher_desc }}">
                        {% else %}
                            <input type="text" class="form-control" name="teacher_desc">
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="thumbnail-form">缩略图</label>
                        <div class="input-group">
                            {% if course %}
                                <input type="text" class="form-control" name="thumbnail" id="thumbnail-form" value="{{ course.thumbnail }}">
                            {% else %}
                                <input type="text" class="form-control" name="thumbnail" id="thumbnail-form">
                            {% endif %}
                            <span class="input-group-btn">
                                <label class="btn btn-default btn-file">
                                    上传图片
                                    <input hidden type="file" class="btn btn-default" id="thumbnail-btn">
                                </label>

                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="thumbnail-form">视频链接</label>
                        <div class="input-group">
                            {% if course %}
                                <input type="text" class="form-control" name="video_url" id="" value="{{ course.video_url }}">
                            {% else %}
                                <input type="text" class="form-control" name="video_url" id="">
                            {% endif %}
                            <span class="input-group-btn">
                                <label class="btn btn-default btn-file">
                                    上传视频
                                    <input hidden type="file" class="btn btn-default" id="video-thumbnail-btn">
                                </label>
                            </span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title-form">时长</label>
                        {% if course %}
                            <input type="text" class="form-control" name="duration"  value="{{ course.duration }}">
                        {% else %}
                            <input type="text" class="form-control" name="duration">
                        {% endif %}
                    </div>
                    <div class="form-group" style="display:none;" id="progress-group">
                        <div class="progress">
                            <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" id="progressbar"
                                 aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: 0">
                                <span class="sr-only">0%</span>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="title-form">价格</label>
                        {% if course %}
                            <input type="text" class="form-control" name="price"  value="{{ course.price }}">
                        {% else %}
                            <input type="text" class="form-control" name="price">
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="title-form">课程大纲</label>
                        {% if course %}
                            <input type="text" class="form-control" name="catalog"  value="{{ course.catalog }}">
                        {% else %}
                            <input type="text" class="form-control" name="catalog">
                        {% endif %}
                    </div>
                    <div class="form-group">
                        <label for="content-form">课程介绍</label>
                        <script id="editor" type="text/plain">
                            {{ course.course_desc|safe }}
                        </script>
                    </div>
                </div>
                <div class="box-footer">
                    {% if course %}
                        <button class="btn btn-primary pull-right" id="submit-btn" data-course-id="{{ course.id }}">发布课程</button>
                    {% else %}
                        <button class="btn btn-primary pull-right" id="submit-btn">发布课程</button>
                    {% endif %}
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}